import { DoubleSide, Mesh, MeshBasicMaterial, PlaneBufferGeometry, PointsMaterial, TextureLoader } from 'three';
import config from './config';



function createPointMesh(size, x, y) {
    const plane = new PlaneBufferGeometry();
    const material = new MeshBasicMaterial({
        map: new TextureLoader().load('../assets/贴图.png'),
        transparent: true,
        opacity: 0.6,
        side: DoubleSide
    });
    const mesh = new Mesh(plane, material);
    mesh.scale.set(size, size, size);
    mesh.position.set(x, y, 0);
    return mesh;
}



function createCircle(size, x, y) {
    const planeCircle = new PlaneBufferGeometry(1, 1);
    const materialCircle = new MeshBasicMaterial({  //不能全局创建 需要初始化
        color: 0x00ffff,
        map: new TextureLoader().load('../assets/光圈贴图.png'),
        transparent: true,
        depthWrite: false //避免光圈之间重叠的闪烁现象
        // side:DoubleSide
    });
    const mesh = new Mesh(planeCircle, materialCircle);
    mesh.scale.set(size, size, size);
    mesh.position.set(x, y, 0);
    return mesh;
}

export { createPointMesh, createCircle };